//
//  ViewController.m
//  07_UIViewControllerLifeCycle
//
//  Created by dllo on 16/7/22.
//  Copyright © 2016年 yh. All rights reserved.
//

#import "ViewController.h"
#import "FirstViewController.h"

@interface ViewController ()

@end

@implementation ViewController
#pragma mark - Life Cycle2
// push一个新的视图控制器时
// loadView viewDidLoad viewWillAppear 这三个方法会插在上个视图的 viewWillDisappear和viewDidDisappear之间
- (void)loadView {
    [super loadView];
    NSLog(@"%@------%s",[self class], __FUNCTION__);
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    NSLog(@"%@------%s",[self class], __FUNCTION__);
    self.view.backgroundColor = [UIColor redColor];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(barClick:)];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    NSLog(@"%@------%s",[self class], __FUNCTION__);
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    NSLog(@"%@------%s",[self class], __FUNCTION__);
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    NSLog(@"%@------%s",[self class], __FUNCTION__);
}

- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
    NSLog(@"%@------%s",[self class], __FUNCTION__);
}

#pragma mark - buttonClick

- (void)barClick:(UIBarButtonItem *)button {
    FirstViewController *VC = [[FirstViewController alloc] init];
    [self.navigationController pushViewController:VC animated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
